<template>
  <div class="hello">
    <h1>{{type}}数字是：{{count}}{{qqq}}</h1>
    <!-- <h1>数字是：{{count2}}</h1>
    <h1>数字是：{{count3}}</h1>
    <h1>数字是：{{count4}}</h1>
    <h1>数字是：{{count5}}</h1> -->
    <!-- <input
      type="text"
      v-model='count'
    > -->
    <button @click='add'>+</button>
    <button @click='addA'>a+</button>
    {{aaa}}
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "HelloWorld",
  props: {
    msg: String,
  },
  data() {
    return {
      qqq: this.$store.state.count,
    };
  },
  computed: {
    ...mapState("MYA", ["a"]),
    ...mapState({
      mycount: "count",
      count2: "count2",
      count3: "count3",
      count4: "count4",
      count5: "count5",
    }),
    type() {
      return this.$store.getters.type;
    },
    count() {
      return this.$store.state.count;
    },
    aaa() {
      return this.$store.state.MYA.a;
    },
    // count: {
    //   get() {
    //     return this.$store.state.count;
    //   },
    //   set(val) {
    //     this.$store.commit("add", {
    //       n: val,
    //     });
    //   },
    // },
  },
  methods: {
    addA() {
      this.$store.commit("MYA/add", {
        n: 200,
      });
    },
    add() {
      this.$store.commit("add", {
        n: 200,
      });
      // this.$store.commit("add", {
      //   n: 111,
      // });
      // this.$store.commit("add", {
      //   n: 222,
      // });
      // this.$store.commit("add", {
      //   n: 333,
      // });
      // this.$store.state.count += 200;
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
